<template>
  <div class="padding-lr20">
    <div class="form">
      <ul>
        <li class="item_li">
          <div class="item_left">
            <span class="span_li">机构类型</span>
          </div>
          <div class="item_right flex-grow padding-left-15">
            <input disabled type="text" :value="name" />
          </div>
        </li>
        <li class="item_li" v-for="(items,indexs) in col1_val" :key="indexs+items">
          <div class="item_left">
            <span class="span_li">主营业务</span>
          </div>
          <div class="jy_picker flex-grow flex padding-left-15 item_right">
            <van-cell @click="col1_click(indexs)" :value="items.text" />
          </div>
          <div class="handle">
            <i class="iconfont icon-jiahao" @click="addzs(indexs)"></i>
            <i class="iconfont icon-jian" @click="remzs(indexs)"></i>
          </div>
        </li>
        <li class="item_li">
          <div class="item_left">
            <span class="span_li">业务手机</span>
          </div>
          <div class="item_right flex-grow">
            <input type="text" v-model="sms_phone" maxlength="11" placeholder="此手机号用于接收招商申请通知短信" />
          </div>
          <span class="xing" style="font-size: 14px;">*</span>
        </li>
        <li class="item_li" v-for="(item,index) in objClass" :key="index">
          <div class="item_left">
            <span class="span_li">{{item.c_name}}</span>
          </div>
          <div class="item_right flex-grow">
            <!-- 手机号 -->
            <input
              v-if="item.field_type == 1"
              type="text"
              v-model="objValue[item.field_name]"
              maxlength="11"
              :placeholder="item.tips"
            />
            <!-- 年月日 -->
            <div v-if="item.field_type == 2">
              <el-date-picker v-model="objValue[item.field_name]" type="date" placeholder="选择日期"></el-date-picker>
            </div>
            <!-- 年月日时分秒 -->
            <div v-if="item.field_type == 3">
              <el-date-picker
                v-model="objValue[item.field_name]"
                type="datetime"
                placeholder="选择日期时间"
              ></el-date-picker>
            </div>
            <!-- 单行文本 -->
            <input
              v-if="item.field_type == 4"
              type="text"
              maxlength="200"
              v-model="objValue[item.field_name]"
              :placeholder="item.tips"
            />
            <!-- 多行文本 -->
            <textarea
              rows="3"
              v-if="item.field_type == 5"
              v-model="objValue[item.field_name]"
              :placeholder="item.tips"
            ></textarea>
            <!-- 单图 -->
            <div class="uploadBox" v-if="item.field_type == 6">
              <!-- <van-uploader v-model="item.fileList" :name="item.field_name" :after-read="afterRead" :max-count="1" /> -->
              <imgedit
                @callback="setimgurl($event, item.field_name)"
                :imgUrl="objValue[item.field_name] || $upimg"
              ></imgedit>
            </div>
            <!-- 文字编辑器 -->
            <div class="flex-grow" v-if="item.field_type == 7">
              <quill-editor
                v-model="objValue[item.field_name]"
                ref="myQuillEditor"
                :options="editorOption"
                @blur="onEditorBlur($event)"
                @focus="onEditorFocus($event)"
                @change="onEditorChange($event, item.field_name)"
              ></quill-editor>
            </div>
            <!-- 图文编辑器 -->
            <div class="flex-grow" v-if="item.field_type == 8">
              <quill-editor
                v-model="objValue[item.field_name]"
                ref="myQuillEditor"
                :options="editorOptions"
                @blur="onEditorBlurs($event)"
                @focus="onEditorFocuss($event)"
                @change="onEditorChanges($event, item.field_name)"
              ></quill-editor>
            </div>
            <!-- 单选 -->
            <div class="flex-grow line-40" v-if="item.field_type == 9">
              <el-radio
                v-for="(items,indexs) in item.label_yiji"
                :key="indexs"
                v-model="objValue[item.field_name]"
                :label="items.id"
              >{{items.title}}</el-radio>
            </div>
            <!-- 多选 -->
            <div class="flex-grow line-40" v-if="item.field_type == 10">
              <el-checkbox-group
                v-for="(items,indexs) in item.label_yiji"
                :key="indexs"
                v-model="objValue[item.field_name]"
              >
                <el-checkbox :label="items.id">{{items.title}}</el-checkbox>
              </el-checkbox-group>
            </div>
            <!-- 多级联动 -->
            <div class="flex-grow line-40 flex" v-if="item.field_type == 11">
              <van-cell
                @click="col3_click(item, item.cate_index, item.field_name, index)"
                :value="item.text"
              />
              <van-popup v-model="item.show" position="bottom">
                <van-picker
                  show-toolbar
                  :columns="item.label_yiji"
                  value-key="title"
                  :attr-data="item.label_yiji"
                  :attr-name="item.field_name"
                  :attr-index="index"
                  :attr-level="item.cate_level"
                  :attr-cate_index="item.cate_index"
                  ref="picker3"
                  @confirm="getType3"
                  @cancel="onCancel"
                />
              </van-popup>
            </div>
            <!-- 地区 -->
            <div class="flex-grow line-40" v-if="item.field_type == 13">
              <van-cell @click="col2_click" :value="col2_val.text" />
            </div>
            <span class="xing">{{item.is_notnull == 1 ? '*' : ''}}</span>
          </div>
        </li>
        <div style="font-size: 14px;padding: 10px 0;color: #999;text-align: right;">注：*号为必填项</div>
      </ul>
    </div>

    <div class="btn" @click="sub">完成</div>

    <!-- 主营业务 -->
    <van-popup v-model="show1" position="bottom" :lazy-render="false">
      <van-picker
        ref="picker1"
        show-toolbar
        :columns="col1"
        value-key="type_name"
        @confirm="getType1"
        @cancel="onCancel"
      />
    </van-popup>
    <!-- 地区 三级联动 -->
    <van-popup v-model="show2" position="bottom" :lazy-render="false">
      <van-picker
        ref="picker2"
        show-toolbar
        :columns="col2"
        value-key="name"
        @confirm="getType2"
        @cancel="onCancel"
      />
    </van-popup>

    <van-overlay :show="overlay" @click="overlay = false">
      <div class="wrapper" @click.stop>
        <div class="block">
          <van-loading size="40px" vertical>图片保存中，请耐心等待...</van-loading>
        </div>
      </div>
    </van-overlay>
  </div>
</template>

<script>
import * as qiniu from "qiniu-js";
import imgedit from "../components/imgedit";
const toolbarOptions = [
  ["bold", "italic", "underline", "strike"], //加粗，斜体，下划线，删除线
  ["blockquote", "code-block"], //引用，代码块

  [{ header: 1 }, { header: 2 }], // 标题，键值对的形式；1、2表示字体大小
  [{ list: "ordered" }, { list: "bullet" }], //列表
  [{ script: "sub" }, { script: "super" }], // 上下标
  [{ indent: "-1" }, { indent: "+1" }], // 缩进
  [{ direction: "rtl" }], // 文本方向

  [{ size: ["small", false, "large", "huge"] }], // 字体大小
  [{ header: [1, 2, 3, 4, 5, 6, false] }], //几级标题

  [{ color: [] }, { background: [] }], // 字体颜色，字体背景颜色
  [{ font: [] }], //字体
  [{ align: [] }], //对齐方式

  ["clean"] //清除字体样式
];
export default {
  components: {
    imgedit
  },
  data() {
    var that = this;
    return {
      overlay: false,
      addShow: true,
      ps: "",
      // 主营业务
      show1: false,
      col1: [], // 公用二级 三级
      col1_index: 0, // 要更改的目标的下标  通过col1_click
      col1_val: [], // 对应的 文本展示，二级id，三级id, 四级id

      // 地区  三级联动
      show2: false,
      col2: [], // 公用一级 二级 三级
      col2_val: {
        text: "请选择",
        one_id: "",
        two_id: "",
        three_id: "",
        id: ""
      }, // 选中的地区id,
      col3: [], // 公用一级 二级 三级
      col3_val: {
        text: "请选择",
        one_id: "",
        two_id: "",
        three_id: ""
      }, // 选中的id,
      cate_index: "",

      // 完善信息
      sms_phone: "",
      type_id: "", // 一级分类
      name: "",
      objClass: "", // 十三中分类
      objValue: {}, // 十三种分类的v-model
      editorOption: {
        placeholder: "请输入",
        modules: {
          toolbar: toolbarOptions
        }
      }, // 富文本配置 文本编辑器
      editorOptions: {
        placeholder: "请输入"
      }, // 图文编辑器
      classList: {}
    };
  },
  mounted() {
    document.querySelector("html").style.backgroundColor = "#ffffff";
    this.name = this.$route.query.type_name;
    this.getInfo();
  },
  methods: {
    setimgurl(e, name) {
      this.overlay = true;
      this.canvasDataURL(e, name);
    },
    base64ToFile(urlData, fileName) {
      let arr = urlData.split(",");
      let mime = arr[0].match(/:(.*?);/)[1];
      let bytes = atob(arr[1]); // 解码base64
      let n = bytes.length;
      let ia = new Uint8Array(n);
      while (n--) {
        ia[n] = bytes.charCodeAt(n);
      }
      return new File([ia], fileName, { type: mime });
    },
    // 压缩图片宽400 转化二进制 请求接口
    canvasDataURL(base64, name) {
      var img = new Image();
      let that = this;
      img.src = base64;
      img.onload = function() {
        //默认按照比例压缩
        var scale = this.width / this.height;
        //规定压缩后的大小
        var canvasWidth = 400;
        var canvasHeight = canvasWidth / scale;
        //生成canvas
        var canvas = document.createElement("canvas");
        var ctx = canvas.getContext("2d");
        //创建节点属性
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;
        var anw = document.createAttribute("width");
        anw.nodeValue = canvasWidth;
        var anh = document.createAttribute("height");
        anh.nodeValue = canvasHeight;
        canvas.setAttributeNode(anw);
        canvas.setAttributeNode(anh);
        ctx.drawImage(this, 0, 0, canvasWidth, canvasHeight);
        //图像质量,值越小，所绘制出的图像越模糊
        var quality = 0.1;
        var base64String = canvas.toDataURL(
          "img/png,img/jpg,img/jpeg",
          quality
        );
        //通过base64获取二进制文件
        let img = that.base64ToFile(base64String, "header.png");
        that.afterRead(img, name);
      };
    },
    getClass() {
      this.$axios
        .post("/home/organization", {
          token: localStorage.getItem("qx_token")
        })
        .then(res => {
          for (let i in res.data.data) {
            if (this.type_id == res.data.data[i].id) {
              this.name = res.data.data[i].type_name;
            }
          }
        });
    },
    // 获取主营类型
    getCate() {
      this.$axios
        .post("/home/canvassType", {
          token: window.localStorage.getItem("qx_token"),
          otype_id: this.type_id
        })
        .then(res => {
          this.col1 = res.data.data.attract;
          for (let i in this.col1) {
            if (this.col1[i].Ent_type_3.length == 0) {
              this.col1[i].Ent_type_3.push({
                type_name: "空",
                id: 0
              });
            }
            this.col1[i].children = this.col1[i].Ent_type_3;

            for (let r in this.col1[i].children) {
              if (
                this.col1[i].children[r].Ent_type_4 &&
                this.col1[i].children[r].Ent_type_4.length == 0
              ) {
                this.col1[i].children[r].Ent_type_4.push({
                  type_name: "空",
                  id: 0
                });
              }
              this.col1[i].children[r].children = this.col1[i].children[
                r
              ].Ent_type_4;
            }
          }
        });
    },
    // 回显
    getInfo() {
      this.$axios
        .post("/home/entInfo", {
          token: localStorage.getItem("qx_token")
        })
        .then(res => {
          let data = res.data.data;
          this.type_id = data.type_id;
          let cate_index = 0; // 多级联动下标

          this.getClass();
          this.getCate();
          this.getProvince();
          // 主营类型
          for (let p in data.attract) {
            this.col1_val.push({
              text: `${data.attract[p].type_name},${data.attract[p].Ent_type_3.type_name},${data.attract[p].Ent_type_4.type_name}`,
              two_id: data.attract[p].second_level,
              three_id: data.attract[p].three_level,
              four_id: data.attract[p].four_level
            });
          }

          // 十三种类型
          this.sms_phone = data.info["sms_phone"];
          for (let i in data.field) {
            data.field[i].show = false;
            data.field[i][data.field[i].field_name] = "";
            if (
              data.field[i].field_type == 10 ||
              data.field[i].field_type == 11
            ) {
              // 多选
              let name = data.info[data.field[i].field_name];
              let name2 = name.substring(1, name.length - 1); // 字符串删除前后的逗号
              let name3 = name2.split(",").filter(item => item);
              let name4 = name3.map(Number);
              this.$set(this.objValue, data.field[i].field_name, name4);
            } else if (
              data.field[i].field_type == 7 ||
              data.field[i].field_type == 8
            ) {
              if (data.info[data.field[i].field_name] != null) {
                this.$set(
                  this.objValue,
                  data.field[i].field_name,
                  data.info[data.field[i].field_name].replace(
                    /(<\/?a.*?>)|(<\/?span.*?>)/g,
                    ""
                  )
                );
              }
            } else if (data.field[i].field_name == "sex") {
              this.$set(
                this.objValue,
                "sex",
                parseInt(data.info[data.field[i].field_name])
              );
            } else if (data.field[i].field_type == 6) {
              // data.field[i].fileList = [{ url: data.info[data.field[i].field_name] }]
              this.$set(
                this.objValue,
                data.field[i].field_name,
                data.info[data.field[i].field_name]
              );
            } else if (data.field[i].field_name == "area_name") {
              let area = data.info[data.field[i].field_name].split(",");
              this.$set(
                this.objValue,
                data.field[i].field_name,
                data.info[data.field[i].field_name]
              );
              this.col2_val.id = data.info[data.field[i].field_name];
              console.log(this.col2_val.id);
              for (let a in this.col2) {
                if (this.col2[a].id == area[0]) {
                  for (let b in this.col2[a].children) {
                    if (this.col2[a].children[b].id == area[1]) {
                      for (let c in this.col2[a].children[b].children) {
                        if (
                          this.col2[a].children[b].children[c].id == area[2]
                        ) {
                          this.$refs.picker2.setIndexes([a, b, c]);
                          this.col2_val.text = `${this.col2[a].name},${this.col2[a].children[b].name},${this.col2[a].children[b].children[c].name}`;
                        }
                      }
                    }
                  }
                }
              }
            } else {
              this.$set(
                this.objValue,
                data.field[i].field_name,
                data.info[data.field[i].field_name]
              );
            }
          }

          this.objClass = data.field;
          this.getc();
        });
    },
    getc() {
      let cate_index = 0; // 多级联动下标
      let res_data = this.objClass;
      for (let i in res_data) {
        if (res_data[i].field_type == 11) {
          res_data[i].text = "请选择";
          res_data[i].cate_index = cate_index;
          cate_index++;
          res_data[i].show = false;
          for (let q in res_data[i].label_yiji) {
            this.$axios
              .post("/common/lowerLevel", {
                id: res_data[i].label_yiji[q].id,
                manage_id: res_data[i].label_yiji[q].manage_id
              })
              .then(res => {
                if (res.data.data.length == 0) {
                  res_data[i].label_yiji[q].children = [
                    { title: "", id: 0, children: [{ title: "", id: 0 }] }
                  ];
                } else {
                  res_data[i].label_yiji[q].children = res.data.data;
                  if (res_data[i].cate_level == 3) {
                    for (let w in res_data[i].label_yiji[q].children) {
                      this.$axios
                        .post("/common/lowerLevel", {
                          id: res_data[i].label_yiji[q].children[w].id,
                          manage_id:
                            res_data[i].label_yiji[q].children[w].manage_id
                        })
                        .then(res => {
                          if (res.data.data.length == 0) {
                            res_data[i].label_yiji[q].children[w].children = [
                              { title: "", id: 0 }
                            ];
                            if (w >= res_data[i].label_yiji.length - 1) {
                              this.col3_re(
                                res_data[i],
                                res_data[i]["field_name"],
                                i
                              );
                            }
                          } else {
                            res_data[i].label_yiji[q].children[w].children =
                              res.data.data;
                            if (w >= res_data[i].label_yiji.length - 1) {
                              this.col3_re(
                                res_data[i],
                                res_data[i]["field_name"],
                                i
                              );
                            }
                          }
                        });
                    }
                  }
                }
                if (q >= res_data[i].label_yiji.length - 1) {
                  this.col3_re(res_data[i], res_data[i]["field_name"], i);
                }
              });
          }
        }
      }
    },
    // 单图上传
    afterRead(file, name) {
      let param = new FormData();
      param.append("file", file);
      // param.append("type", "4");
      param.append("type", "7");
      let config = {
        headers: { "Content-Type": "multipart/form-data" }
      };
      this.$axios
        .post("/common/upload/image/qiniu", param, config)
        .then(res => {
          if (res.data.code == 0) {
            this.objValue[name] = res.data.url;
          }
          this.$toast(res.data.msg);
          this.overlay = false;
        });
    },
    col1_click(index) {
      this.show1 = true;
      this.col1_index = index;

      for (let i in this.col1) {
        if (this.col1[i].id == this.col1_val[index].two_id) {
          for (let u in this.col1[i].children) {
            if (this.col1[i].children[u].id == this.col1_val[index].three_id) {
              for (let c in this.col1[i].children[u].children) {
                if (
                  this.col1[i].children[u].children[c].id ==
                  this.col1_val[index].four_id
                ) {
                  this.$refs.picker1.setIndexes([i, u, c]);
                }
              }
            }
          }
        }
      }
    },
    col2_click() {
      this.show2 = true;
    },
    col3_re(e, name, indexs) {
      for (let i in e.label_yiji) {
        // 碰到一个bug  如果是这种后来添加的对象  直接赋值和$set 都不会改变数据渲染
        // 但是只要我一改变这个数组下的别的v-model的数据  就会发生更新
        // getProvince() 就是用来更新其中的地区的v-model 让他发生变化
        // getc() 和  col3_re() 都是getInfo()的处理
        setTimeout(() => {
          if (e.label_yiji[i].id == this.objValue[name][0]) {
            this.objClass[indexs].text = `${e.label_yiji[i].title}`;
            this.getClass();
            for (let u in e.label_yiji[i].children) {
              if (e.label_yiji[i].children[u].id == this.objValue[name][1]) {
                this.objClass[
                  indexs
                ].text = `${e.label_yiji[i].title},${e.label_yiji[i].children[u].title}`;
                this.getClass();
                for (let y in e.label_yiji[i].children[u].children) {
                  if (
                    e.label_yiji[i].children[u].children[y].id ==
                    this.objValue[name][2]
                  ) {
                    this.objClass[
                      indexs
                    ].text = `${e.label_yiji[i].title},${e.label_yiji[i].children[u].title},${e.label_yiji[i].children[u].children[y].title}`;
                    this.getClass();
                  }
                }
              }
            }
          }
        }, 200);
      }
    },
    col3_click(e, index, name, indexs) {
      e.show = true;
      this.cate_index = index;
      setTimeout(() => {
        let picker = this.$refs.picker3;
        for (let s in picker) {
          if (picker[s].$attrs["attr-cate_index"] == this.cate_index) {
            for (let i in e.label_yiji) {
              if (e.label_yiji[i].id == this.objValue[name][0]) {
                picker[s].setIndexes([i]);
                for (let u in e.label_yiji[i].children) {
                  if (
                    e.label_yiji[i].children[u].id == this.objValue[name][1]
                  ) {
                    picker[s].setIndexes([i, u]);
                    if (e.cate_level == 3) {
                      for (let y in e.label_yiji[i].children[u]["children"]) {
                        if (
                          e.label_yiji[i].children[u]["children"][y].id ==
                          this.objValue[name][2]
                        ) {
                          picker[s].setIndexes([i, u, y]);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }, 200);
    },
    onCancel() {
      this.show1 = false;
      this.show2 = false;
      for (let i in this.objClass) {
        this.objClass[i].show = false;
      }
    },
    // 添加招商类型
    addzs(index) {
      if (this.col1_val.length > 9) {
        this.$toast("最多只能添加10个");
        return false;
      }
      this.col1_val.push({
        text: "请选择",
        two_id: "",
        three_id: "",
        four_id: ""
      });
    },
    remzs(index) {
      if (this.col1_val.length == 1) {
        this.$toast("最少要添加一个");
        return false;
      }
      this.col1_val.splice(index, 1);
    },
    // 主营业务确定
    getType1(e, index) {
      let two_id = this.col1[index[0]].id;
      let three_id = this.col1[index[0]].children[index[1]].id;
      let four_id = this.col1[index[0]].children[index[1]].children[index[2]]
        .id;

      for (let i in this.col1_val) {
        if (four_id == 0) {
          this.$toast("类型不可以为空哦~");
          return false;
        } else if (four_id == this.col1_val[i].four_id) {
          this.$toast("类型不可以重复哦~");
          return false;
        }
      }

      this.col1_val[this.col1_index].text = `${e[0]},${e[1]},${e[2]}`;
      this.col1_val[this.col1_index].two_id = two_id;
      this.col1_val[this.col1_index].three_id = three_id;
      this.col1_val[this.col1_index].four_id = four_id;
      this.show1 = false;
    },
    // 地区确定
    getType2(e, index) {
      let one_id = this.col2[index[0]].id;
      let two_id = this.col2[index[0]].children[index[1]].id;
      let three_id = this.col2[index[0]].children[index[1]].children[index[2]]
        .id;

      this.col2_val.text = `${e[0]},${e[1]},${e[2]}`;
      this.col2_val.id = `${one_id},${two_id},${three_id}`;
      this.show2 = false;
    },
    getType3(e, index) {
      for (let i in this.$refs.picker3) {
        if (
          this.$refs.picker3[i].$attrs["attr-cate_index"] == this.cate_index
        ) {
          let picker = this.$refs.picker3[i];
          let name = picker.$attrs["attr-name"]; // 当前二三级联动的字段名
          let indexs = picker.$attrs["attr-index"]; // 当前二三联动的字段在objClass的下标

          let one_id = picker.getColumnValues(0);
          let two_id = picker.getColumnValues(1);
          let three_id = picker.getColumnValues(2);
          this.objValue[name] = [
            one_id[index[0]].id,
            two_id[index[1]].id,
            three_id ? three_id[index[2]].id : ""
          ];
          this.objClass[indexs].text = e.join(",");
          this.objClass[indexs].show = false;
          return false;
        }
      }
    },
    // 地址
    getProvince() {
      if (localStorage.getItem("col2")) {
        this.col2 = JSON.parse(localStorage.getItem("col2"));
        return false;
      }
      this.$axios.post("/common/getRegion/all").then(res => {
        this.col2 = res.data.data;
        localStorage.setItem("col2", JSON.stringify(res.data.data));
      });
    },
    sub() {
      this.$set(this.objValue, "type_id", this.type_id); // 一级id
      this.$set(this.objValue, "area_name", this.col2_val.id);
      this.$set(this.objValue, "sms_phone", this.sms_phone); // 通知手机

      let type = false;
      if (!this.sms_phone) {
        this.$toast("请输入业务手机");
        return false;
      }
      // 必填项
      for (let q in this.objClass) {
        if (
          this.objClass[q].is_notnull == 1 &&
          !this.objValue[this.objClass[q].field_name]
        ) {
          console.log(this.objValue);
          this.$toast(this.objClass[q].c_name + "不能为空");
          return false;
        }
        if (q == this.objClass.length - 1) {
          type = true;
        }
      }
      if (type) {
        // 最多10种主营业务
        for (let g in this.col1_val) {
          if (
            !this.col1_val[g].four_id ||
            !this.col1_val[g].three_id ||
            !this.col1_val[g].two_id
          ) {
            this.$toast("请选择主营业务");
            return false;
          }
        }

        // 验证手机号
        if (
          this.objValue["enterprise_phone"] &&
          !/^1[3456789][0-9]{9}$/.test(
            this.objValue["enterprise_phone"]
          )
        ) {
          this.$toast("请输入正确手机号");
          return false;
        }

        for (let p in this.objValue) {
          if (p == "jyfl" && this.objValue["jyfl"].length == 0) {
            this.$toast("经营分类请填写完整");
            return false;
          }
          if (
            this.objValue[p] != undefined &&
            this.objValue[p].constructor == Array
          ) {
            let name = this.objValue[p].filter(item => item);
            this.objValue[p] = "," + name.join(",") + ",";
          }
        }
        // 分类
        let attract = [];
        for (let i in this.col1_val) {
          attract[i] = {
            second_level: this.col1_val[i].two_id,
            three_level: this.col1_val[i].three_id,
            four_level: this.col1_val[i].four_id
          };
        }
        let basic = this.objValue;

        this.$axios
          .post("/home/submitEntInfo", {
            token: window.localStorage.getItem("qx_token"),
            attract: attract,
            basic: basic
          })
          .then(res => {
            if (res.data.code == 0) {
              this.$toast("成功");
              window.localStorage.setItem("step", -1);
              this.$axios
                .post("/home/getEntinfo", {
                  token: window.localStorage.getItem("qx_token")
                })
                .then(res => {
                  window.localStorage.setItem(
                    "ent_info",
                    JSON.stringify(res.data.data.ent_info)
                  );
                  window.localStorage.setItem(
                    "level",
                    res.data.data.function_choice
                      ? res.data.data.function_choice
                      : false
                  );
                });
              if (this.$route.query.pointAddress) {
                this.$router.push({
                  name: this.$route.query.pointAddress
                });
                return false;
              }
              let time = setInterval(() => {
                if (window.localStorage.getItem("ent_info")) {
                  this.$router.push({
                    name: "mine"
                  });
                  clearInterval(time);
                }
              }, 500);
            }
          });
      }
    },
    onEditorBlur() {}, // 失去焦点事件
    onEditorFocus() {}, // 获得焦点事件
    onEditorChange(e, text) {
      if (e.html.indexOf("&lt;a") >= 0 || e.html.indexOf("<a") >= 0) {
        this.objValue[text] = this.objValue[text].replace(
          /(<\/?a.*?>)|(<\/?span.*?>)/g,
          ""
        );
      }
    }, // 内容改变事件
    onEditorBlurs() {}, // 失去焦点事件
    onEditorFocuss() {}, // 获得焦点事件
    onEditorChanges(e, text) {
      if (e.html.indexOf("&lt;a") >= 0 || e.html.indexOf("<a") >= 0) {
        this.objValue[text] = this.objValue[text].replace(
          /(<\/?a.*?>)|(<\/?span.*?>)/g,
          ""
        );
      }
    } // 内容改变事件
  }
};
</script>
<style scoped>
.shili {
  width: 120px;
  height: 120px;
}
.el-header {
  line-height: 80px;
}

.el-footer {
  background: #3d3f41;
}

.el-main {
  background-size: cover;
  padding: 80px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 130px) !important;
}

.mid1200 {
  max-width: 1200px;
  margin: 0 auto;
}

.after:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}

.loginForm {
  margin: 0 auto;
  width: 610px;
}

.loginForm .title {
  font-weight: normal;
  color: #333;
  font-size: 24px;
  line-height: 2em;
  text-align: center;
  padding: 15px 0;
}

.formBox .form {
  background: #f7f7f7;
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
  overflow: hidden;
  padding: 0 35px 30px;
}

.formBox .form {
  background: #f7f7f7;
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
  overflow: hidden;
  padding: 20px 35px 30px;
}

.form li {
  padding: 0.1rem 0;
  line-height: 0.8rem;
  border-bottom: 1px solid #f0f0f0;
  font-size: 18px;
  position: relative;
  overflow: hidden;
}

.form li.pl40 {
  padding-left: 40px;
}

.form li.pl95 {
  padding-left: 95px;
}

.form li.pr120 {
  padding-right: 120px;
}

.borb0 {
  border-bottom: 0 !important;
}

.form input {
  height: 0.8rem;
  background: no-repeat;
  width: 100%;
  outline: 0;
  font-size: 0.28rem;
}

.form li > i {
  font-size: 24px;
  position: absolute;
  left: 5px;
  top: 50%;
  margin-top: -12px;
}

.form li.forgetli {
  font-size: 16px;
  color: #333;
  padding: 30px 0;
}

.form li.phone_li span {
  color: #333333;
  font-size: 18px;
  height: 1em;
  line-height: 1em;
  position: absolute;
  left: 40px;
  top: 50%;
  margin-top: -0.5em;
  border-right: 1px solid #333;
  padding-right: 10px;
  display: block;
}

.loginBtn {
  display: block;
  width: 100%;
  border-radius: 2px;
  background: #ff7b00;
  font-size: 24px;
  color: #fff;
  letter-spacing: 5px;
  height: 60px;
}

.tip {
  margin-top: 30px;
  text-align: center;
  color: #fff;
  font-size: 16px;
}

.tip a {
  color: #ff7b00;
  cursor: default;
}

.stepLine {
  width: 428px;
  margin: 0 auto 35px;
}

.stepLine dl {
  float: left;
  width: 50%;
  position: relative;
}

.stepLine dl dt {
  width: 56px;
  height: 42px;
  line-height: 42px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  display: inline-block;
  margin: 0 5px;
  position: relative;
  z-index: 2;
  margin-bottom: 10px;
}

.stepLine dl dd {
  font-size: 16px;
  color: #ffffff;
  line-height: 2em;
}

.stepLine dl:before {
  position: absolute;
  width: 194px;
  height: 1px;
  content: "";
  background: #c0c1c1;
  top: 21px;
}

.stepLine dl.dl1:before {
  left: 20px;
}

.stepLine dl.dl2:before {
  right: 20px;
}

.stepLine dl.dl2 {
  text-align: right;
}

.stepLine.step1 dl.dl1:before {
  background: #ff7b00;
}

.stepLine.step2 dl.dl2:before {
  background: #ff7b00;
}
.form li .item_left {
  font-size: 18px;
  color: #333;
  line-height: 0.8rem;
  height: 0.8rem;
  display: flex;
  align-items: center;
}
.form li .item_left i {
  font-size: 24px;
  color: #999;
  margin-right: 10px;
}
.form li > input {
  width: 430px;
  font-size: 18px;
  color: #999;
}
.form li > input {
  padding: 0 15px;
}
.form li.tips_li {
  font-size: 14px;
  padding: 10px 0;
  color: #999;
}
.uploadBox {
  width: 80px;
  height: 80px;
}
.form li .uploadBox .avatar-uploader {
  display: inline-block;
  margin-right: 30px;
  vertical-align: middle;
}
.form li .uploadBox > img {
  display: inline-block;
  vertical-align: middle;
}
.form li .handle {
  line-height: 0.8rem;
  height: 0.8rem;
  min-width: 1.3rem;
}
.form li .handle i {
  font-size: 0.5rem;
  color: #666;
  margin-left: 0.1rem;
}
.form .loginBtn {
  margin-top: 30px;
}
textarea {
  width: 100%;
  height: auto;
  min-height: 40px;
  line-height: 40px;
}
.form li .span_li {
  min-width: 1.4rem;
  display: inline-block;
  font-size: 0.28rem;
}
.form li .item_right {
  padding-left: 15px;
  padding-right: 30px;
  position: relative;
  font-size: 0.28rem;
  line-height: 0.8rem;
  min-height: 0.8rem;
}
.xing {
  position: absolute;
  right: 0;
  top: 0;
  /* transform: translateY(-50%); */
  color: red;
  line-height: 40px;
}
.shili {
  display: inline-block;
  vertical-align: middle;
}
.iconImg {
  width: 24px;
  height: 24px;
  display: inline-block;
  object-fit: contain;
  margin-right: 10px;
  vertical-align: middle;
}
.line-40 {
  line-height: 0.8rem;
}
.btn {
  background: #fe0000;
  color: white;
  text-align: center;
  padding: 0.3rem 0;
  border-radius: 4px;
  margin: 0.6rem 0;
}
</style>


<style>
.form .van-cell {
  padding: 0 !important;
}
.form .van-cell span {
  min-width: 0.8rem;
  line-height: 0.8rem;
  display: inline-block;
}
.reg .avatar-uploader {
  width: 120px;
  height: 120px;
}
.reg .avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 120px;
  height: 120px;
  background: #fff;
}
.reg .avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.reg .avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
}
.reg .avatar {
  width: 120px;
  height: 120px;
  display: block;
}
.address_picker .el-select {
  width: 143px;
}
.reg .form li .el-input__inner {
  border: 0;
  background: none;
  font-size: 18px;
  color: #999;
  padding-left: 0;
}
.jy_picker .el-select {
  width: 125px;
}
.form .item_li {
  display: flex;
}
.quill-editor .ql-editor {
  font-size: 18px;
  line-height: 1.5;
}
.ql-editor {
  min-height: 100px;
}
.reg .el-progress__text {
  transform: translate(200%, 200%) !important;
}
.van-uploader__upload {
  margin: 0 !important;
}
</style>